/*    */ package com.jcrj.service;
/*    */ 
/*    */ import com.jcrj.dao.FavoriteDao;
/*    */ import com.jcrj.entity.OFavorite;
/*    */ import java.util.List;
/*    */ 
/*    */ public class FavoriteService
/*    */ {
/*    */   private FavoriteDao favoriteDao;
/*    */ 
/*    */   public FavoriteDao getFavoriteDao()
/*    */   {
/* 14 */     return this.favoriteDao;
/*    */   }
/*    */ 
/*    */   public void setFavoriteDao(FavoriteDao favoriteDao) {
/* 18 */     this.favoriteDao = favoriteDao;
/*    */   }
/*    */ 
/*    */   public void saveFavorite(OFavorite favorite) {
/* 22 */     this.favoriteDao.saveFavorite(favorite);
/*    */   }
/*    */ 
/*    */   public List<OFavorite> getFavoriteList(String name, int currentPage, int userId)
/*    */   {
/* 27 */     String hql = "from OFavorite where userId=" + userId;
/* 28 */     if ((name != null) && (!"".equals(name))) {
/* 29 */       hql = hql + " and title like '%" + name.trim() + "%'";
/*    */     }
/* 31 */     hql = hql + " order by  createTime desc";
/* 32 */     return this.favoriteDao.findByPage(hql, currentPage);
/*    */   }
/*    */ 
/*    */   public Long countFavoriteTotal(String name, int userId) {
/* 36 */     String hql = "select count(id) from OFavorite where userId=" + userId;
/* 37 */     if ((name != null) && (!"".equals(name))) {
/* 38 */       hql = hql + " and title like '%" + name.trim() + "%'";
/*    */     }
/* 40 */     return this.favoriteDao.countTotalByHql(hql);
/*    */   }
/*    */ 
/*    */   public void deleteFavorite(String[] ids) {
/* 44 */     if (ids != null) {
/* 45 */       String id = "";
/* 46 */       for (int i = 0; i < ids.length; i++) {
/* 47 */         if (id == "")
/* 48 */           id = id + ids[i];
/*    */         else {
/* 50 */           id = id + "," + ids[i];
/*    */         }
/*    */       }
/* 53 */       String hql = "delete from OFavorite where id in(" + id + ")";
/* 54 */       this.favoriteDao.executeHql(hql);
/*    */     }
/*    */   }
/*    */ }

/* Location:           /Volumes/work/oa/WEB-INF/classes/
 * Qualified Name:     com.jcrj.service.FavoriteService
 * JD-Core Version:    0.6.0
 */